//
//  HomeTableViewController.m
//  GCD
//
//  Created by fangyuan ding on 2020/8/10.
//  Copyright © 2020 fangyuan ding. All rights reserved.
//

#import "HomeTableViewController.h"
#import "GCDViewController.h"
#import "OCTOCViewController.h"
#import "KVOViewController.h"
#import "LayerViewController.h"
#import "PointViewController.h"
#import "PredicateViewController.h"
#import "DateViewController.h"
#import "BlockViewController.h"
#import "DataStorageViewController.h"
#import "TimerViewController.h"
#import "MVVMViewController.h"
#import "InstanceViewController.h"
#import "CircularReferenceViewController.h"
@interface HomeTableViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong)NSArray *titleArray;

@end

@implementation HomeTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleArray = @[@"GCD",@"KVO",@"OCTOC",@"Layer",@"Point",@"Predicate",@"Date",@"Block",@"DataStorage",@"Timer",@"MVVM",@"单例",@"CycleReference"];
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
}

#pragma mark - Table view data source



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titleArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text = self.titleArray[indexPath.row];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if(indexPath.row == 0){
        GCDViewController *gcd = [[GCDViewController alloc]init];
        [self.navigationController pushViewController:gcd animated:YES];
    }else if (indexPath.row == 1){
        KVOViewController *kvo = [[KVOViewController alloc]init];
        [self.navigationController pushViewController:kvo animated:YES];
    }else if (indexPath.row == 2){
        OCTOCViewController *octoc = [[OCTOCViewController alloc]init];
        [self.navigationController pushViewController:octoc animated:YES];
    }else if (indexPath.row == 3){
        LayerViewController *layer = [[LayerViewController alloc]init];
        [self.navigationController pushViewController:layer animated:YES];
    }else if (indexPath.row == 4){
        PointViewController *point = [[PointViewController alloc]init];
        [self.navigationController pushViewController:point animated:YES];
    }else if (indexPath.row == 5){
        PredicateViewController *predicate = [[PredicateViewController alloc]init];
        [self.navigationController pushViewController:predicate animated:YES];
    }else if (indexPath.row == 6){
        DateViewController *date = [[DateViewController alloc]init];
        [self.navigationController pushViewController:date animated:YES];
    }else if (indexPath.row == 7){
        BlockViewController *block = [[BlockViewController alloc]init];
        [self.navigationController pushViewController:block animated:YES];
    }else if (indexPath.row == 8){
        DataStorageViewController *dataStorage = [[DataStorageViewController alloc]init];
        [self.navigationController pushViewController:dataStorage animated:YES];
    }else if (indexPath.row == 9){
        TimerViewController *timer = [[TimerViewController alloc]init];
        [self.navigationController pushViewController:timer animated:YES];
    }else if (indexPath.row == 10){
        MVVMViewController *mvvm = [[MVVMViewController alloc]init];
        [self.navigationController pushViewController:mvvm animated:YES];
    }else if (indexPath.row == 11){
        InstanceViewController *instance = [[InstanceViewController alloc]init];
        [self.navigationController pushViewController:instance animated:YES];
    }else if (indexPath.row == 12){
        CircularReferenceViewController *cycle = [[CircularReferenceViewController alloc]init];
        [self.navigationController pushViewController:cycle animated:YES];
    }
}

@end
